package com.cch.cooperation.api.report.controller;


import com.cch.cooperation.api.auth.dto.LoginUserDTO;
import com.cch.cooperation.api.report.dto.ReportAddDTO;
import com.cch.cooperation.api.report.service.ReportServiceImpl;
import com.cch.cooperation.common.web.response.Response;
import com.cch.cooperation.common.web.session.Session;
import com.cch.cooperation.common.web.session.SessionManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 举报接口
 *
 * @author cch
 */
@Api(tags = "举报接口")
@RestController
@RequestMapping("/api/report")
public class ReportController {

    @Resource
    private ReportServiceImpl reportService;
    @Resource
    private SessionManager sessionManager;

    @ApiOperation("新增举报")
    @PostMapping("/add")
    public Response<Void> add(@RequestBody ReportAddDTO req) {
        Session<LoginUserDTO> session = sessionManager.get();
        req.setUserId(session.getData().getId());
        reportService.add(req);
        return Response.success();
    }
}
